package com.cy.pj.sys.service.impl;

import com.cy.pj.common.annotation.RequiredLog;
import com.cy.pj.sys.Dao.CGBLogsDao;
import com.cy.pj.sys.pojo.CGBLog;
import com.cy.pj.sys.service.CGBLogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Transactional(readOnly = false,rollbackFor = Throwable.class,
isolation = Isolation.READ_COMMITTED)
@Service
public class CGBLogServiceImpl implements CGBLogsService {
    @Autowired
    private CGBLogsDao cgbLogsDao;


    @Transactional(readOnly = false)
    @RequiredLog(operation = "日志查询")//此注解描述的方法为日志切入点方法，标记切入点，可以对注解的方法进行描述、拓展、增加新功能
    @Override
    public List<CGBLog> findLogs(CGBLog CGBLog) {
        List<CGBLog> list=cgbLogsDao.selectLogs(CGBLog);
        return list;
    }

    @Async // @Async 注解作用描述的方法为一个异步切入点方法
    @Override
    public int saveLog(CGBLog CGBLog) {
        return cgbLogsDao.insertLog(CGBLog);
    }

    @RequiredLog(operation = "日志查询")
    @Override
    public CGBLog findById(Long id) {
        return cgbLogsDao.selectById(id);
    }

    @RequiredLog(operation = "删除日志")
    @Override
    public int deleteById(Long... id) {
        return cgbLogsDao.deleteById(id);
    }
}
